package com.flyme.module.file.provider.utils;

import com.polyv.live.bean.request.channel.PLChannelCreateRequest;
import com.polyv.live.bean.request.channel.PLChannelDeleteRequest;
import com.polyv.live.bean.request.channel.PLChannelNameSetRequest;
import com.polyv.live.bean.result.channel.PLChannelCommonResult;
import com.polyv.live.bean.result.channel.PLChannelCreateResult;
import com.polyv.live.service.PLChannelService;
import com.polyv.live.service.impl.PLChannelServiceImpl;

/**
 * 保利威直播
 */
public class PolyvUtil {
    private  static  final  String APPID="f8qdgpjlae";
    private static final String APP_USER_ID = "c0f891cf2e";
    private  static  final  String APPSECRET="564333d2980b49a699d589daae9b5f85";
    /**
     *  创建频道
     */
    public static PLChannelCreateResult crateChannel(String name) {
        PLChannelCreateRequest request = new PLChannelCreateRequest(APPID,APPSECRET);
        request.setUserId(APP_USER_ID);
        request.setChannelPasswd("123456");
        request.setName(name);
        PLChannelService plChannelService = new PLChannelServiceImpl();
        PLChannelCreateResult result = plChannelService.createChannel(request);
        if (null != result && 200 == result.getCode()) {
            return result;
        }else{
            return  null;
        }

    }
    /**
     * 修改直播间名称
     */
    public  static  PLChannelCommonResult updateChannel(Integer id,String name){
        PLChannelNameSetRequest request = new PLChannelNameSetRequest(APPID,APPSECRET);
        request.setName(name);
        PLChannelService plChannelService = new PLChannelServiceImpl();
        PLChannelCommonResult result = plChannelService.setChannelName(id, request);
        if(null != result && 200 == result.getCode()) {
            return result;
        }else{
            return null;
        }

    }

    /**
     * 删除直播间
     */
    public  static  PLChannelCommonResult delChannel(Integer id){
        PLChannelDeleteRequest request = new PLChannelDeleteRequest(APPID,APPSECRET);
        request.setUserId(APP_USER_ID);
        PLChannelService plChannelService = new PLChannelServiceImpl();
        PLChannelCommonResult result = plChannelService.deleteChannel(id, request);
        if(null != result && 200 == result.getCode()) {
            return result;
        }else{
            return null;
        }

    }
}
